/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controlador;
import Facade.VoluntarioFacade;
import Modelo.DaoVoluntario;
import VO.VoluntarioVO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import vista.voluntarioBean;

/**
 *
 * @author Alan
 */
public class EliminarVoluntarioAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    private final static String FAILURE = "failure";

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        voluntarioBean frm = (voluntarioBean)form;
        VoluntarioVO nuevoVoluntario = new VoluntarioVO();
        VoluntarioFacade fcdVoluntario = new VoluntarioFacade();

        //nuevoVoluntario.setIdVoluntario(frm.getIdVoluntario());
        nuevoVoluntario.setRut(frm.getRut());
        nuevoVoluntario.setFechaRetiro(frm.getFechaRetiro());

        //boolean resultado = dao.ingresarVoluntario(nuevoVoluntario);
        boolean resultado = fcdVoluntario.eliminarVoluntario(nuevoVoluntario);

        if(resultado) return mapping.findForward(SUCCESS);
        else return mapping.findForward(FAILURE);
    }
}
